<template>
  <view>
    <uni-section title="违章记录" type="line">
      <uni-collapse>
        <scroll-view scroll-y="true" style="background-color: #fff;" class="filter-scroll-view filter-page">
          <uni-collapse-item :title="item.carnum" v-for="item in violationList">
            <uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据">
              <uni-tr>
                <uni-th align="left">违章图片</uni-th>
                <uni-td align="center">
                  <ImagePreview :classstyle="'width:100%;height:100%;border-radius: 50%;'"
                                :image="item.vehViolationPics" :url="imgurl"></ImagePreview>
                </uni-td>
              </uni-tr>
              <uni-tr>
                <uni-th align="left">订单号</uni-th>
                <uni-td align="center">{{ item.ordernum }}</uni-td>
              </uni-tr>
              <uni-tr>
                <uni-th align="left">违章备注</uni-th>
                <uni-td align="center">{{ item.vehViolationDesc }}</uni-td>
              </uni-tr>
            </uni-table>
          </uni-collapse-item>
          <uni-load-more iconType="circle" :status="nomore"/>
        </scroll-view>

      </uni-collapse>

    </uni-section>
  </view>
</template>

<script>
import {getViolationList} from '../../utils/api/basics.js'

export default {

  data() {
    return {
      loading: true,
      nomore:'',
      imgurl: getApp().globalData.imgUrl,
      queryParams: {
        wxuserId: uni.getStorageSync('useinfo').id,
        shopId: '',
        statusStr: '1,2,4',
        pageSize: 10,
        pageNum: 1,
        total: 0
      },
      violationList: []
    };
  },
  onLoad() {
    this.queryViolation()
  },
  onPullDownRefresh() {
    this.queryParams.pageNum = 1
    this.queryViolation()
  },
  onReachBottom() {
    if (this.queryParams.pageNum >= this.queryParams.total / this.queryParams.pageSize) {
      console.log('mey');
      this.nomore = 'noMore'
    } else {
      this.queryParams.pageNum++
      this.queryViolation()
    }
  },
  methods: {
    queryViolation() {
      this.nomore = 'loading'
      getViolationList(this.queryParams).then(res => {
        if (res.data.code == 200) {
          this.violationList = res.data.rows
          this.queryParams.total = res.data.total
          this.loading = false
          this.nomore = 'more'
        }
      })
    }
  }
}
</script>

<style lang="scss">

</style>
